(cl:in-package #:portable-condition-system)

(setf (documentation
       (find-method #'print-object '(:around) (list (find-class 'restart) (find-class 't)))
       t)
      (format
       nil
       "Print the restart to the provided stream.~@
        ~@
        If *PRINT-ESCAPE* is TRUE, the restart is printed unreadably.~@
        Otherwise, it is reported by means of calling the next printing method."))

(setf (documentation
       (find-method #'print-object '() (list (find-class 'restart) (find-class 't)))
       t)
      (format
       nil
       "Report a restart object to the provided stream.~@
        ~@
        If the report function of the restart is present, then it is called.~@
        Otherwise, if the name of the restart is present, then it is printed.~@
        Otherwise, the restart object is printed unreadably."))

(setf (documentation 'restart-visible-p 'function)
      (format
       nil
       "Return true if the restart should be visible when computed for a given~@
        condition object. If the condition is null, return true; otherwise, if the~@
        restart is associated with a different condition, return false; otherwise,~@
        return true."))

(setf (documentation 'with-condition-restart 'function)
      (format
       nil
       "Associates the provided condition object with multiple provided restart~@
        objects within the dynamic scope of the provided body forms."))

(setf (documentation '*restart-cluster* 'variable)
      (format
       nil
       "A list containing a list of all restart clusters, where a cluster is~@
        a list of restarts established together."))

(setf (documentation 'compute-restarts 'function)
      (format
       nil
       "Return a list of all currently established restarts. If the optional~@
        condition argument is supplied, omits all restarts which are associated~@
        with conditions other than the provided one."))

(setf (documentation 'restart-bind-transform-binding 'function)
      (format
       nil
       "Transforms the RESTART-BIND binding into a MAKE-RESTART form."))

(setf (documentation 'restart-bind 'function)
      (format
       nil
       "Executes the body forms in a dynamic context where the newly~@
        established restarts are available."))

(setf (documentation 'restart-case-make-report-subform 'function)
      (format
       nil
       "Accepts an argument to HANDLER-CASE's :REPORT option and~@
        generates a :REPORT-FUNCTION subform, meant to be spliced~@
        into the HANDLER-BIND binding generated by HANDLER-CASE."))

(setf (documentation 'restart-case-make-interactive-subform 'function)
      (format
       nil
       "Accepts an argument to HANDLER-CASE's :INTERACTIVE option~@
        and generates a[ :INTERACTIVE-FUNCTION subform, meant to be~@
        spliced into the HANDLER-BIND binding generated by HANDLER-CASE."))

(setf (documentation 'restart-case-make-test-subform 'function)
      (format
       nil
       "Accepts an argument to HANDLER-CASE's :TEST option and~@
        generates a :TEST-FUNCTION subform, meant to be spliced~@
        into the HANDLER-BIND binding generated by HANDLER-CASE."))

(setf (documentation 'restart-case-pop-keywords-from-case 'function)
      (format
       nil
       "Accepts the forms of a handler case following the case's~@
        lambda list and parses that form, checking for the presence~@
        of :REPORT, :INTERACTIVE, and :TEST keywords within the case's~@
        body. Returns four values: the body forms of the case remaining~@
        after removing the aforementioned keyword-argument pairs, and the~@
        values of :REPORT, :INTERACTIVE, and :TEST keywords found in the~@
        body (or NIL, if the respective keyword was not found)."))

(setf (documentation 'restart-case-parse-case 'function)
      (format
       nil
       "Parses the provided handler case and returns five values:~@
        restart name, lambda list of the restart case, a list of~@
        HANDLER-BIND keywords meant to be spliced into the handler~@
        binding, the body forms of the handler case, and a globally~@
        unique symbol that is meant to be used as a GO tag within~@
        the main body of HANDLER-CASE."))

(setf (documentation 'restart-case-signaling-form-p 'function)
      (format
       nil
       "Returns true if the expression provided to RESTART-CASE~@
        is a known condition-signaling form whose condition should~@
        be associated with the restarts that are newly established~@
        by HANDLER-CASE."))

(setf (documentation 'restart-case-expand-non-cerror 'function)
      (format
       nil
       "Expands the provided SIGNAL, WARN, or ERROR form into a~@
        signaling form whose condition is associated with the restarts~@
        that are newly established by HANDLER-CASE."))

(setf (documentation 'restart-case-expand-cerror 'function)
      (format
       nil
       "Expands the provided CERROR form into a signaling form whose~@
        condition is associated with the restarts that are newly~@
        established by HANDLER-CASE."))

(setf (documentation 'restart-case-expand-signaling-form 'function)
      (format
       nil
       "Expands the provided signaling form into a signaling form~@
          whose condition is associated with the restarts that are newly~@
          established by HANDLER-CASE."))

(setf (documentation 'restart-case-make-restart-binding 'function)
      (format
       nil
       "Accepts a parsed RESTART-CASE case and generates a RESTART-BIND~@
        binding based on it."))

(setf (documentation 'restart-case-make-restart-case 'function)
      (format
       nil
       "Accepts a parsed RESTART-CASE case and generates a TAGBODY~@
        case based on it."))

(setf (documentation 'restart-case 'function)
      (format
       nil
       "Executes the body forms in a dynamic context where the~@
        newly established restarts are available. Each restart~@
        immediately transfers control to its restart case upon~@
        invocation, executing the body forms of the case and~@
        returning their value from RESTART-CASE."))

(setf (documentation 'with-simple-restart 'function)
      (format
       nil
       "Executes the body forms in a dynamic context where~@
        the newly established restart is available. This restart~@
        immediately transfers control outside the form upon invocation,~@
        returning NIL as its primary value and T as its secondary value."))


(setf (documentation 'maybe-invoke-restart 'function)
      (format
       nil
       "Searches for a restart with the provided restart name,~@
        using the optionally provided condition argument during~@
        the search. If a restart is found, it is invoked;~@
        otherwise, if ERRORP is true, a RESTART-NOT-FOUND error~@
        is signaled. Otherwise, this function returns NIL."))

(setf (documentation 'abort 'function)
      (format
       nil
       "Invokes the most recent ABORT restart. If the optional~@
        condition argument is provided, instead the most recent~@
        ABORT restart that is not associated with any other condition.~@
        If no ABORT restart is available, or the restart fails to~@
        transfer control outside of this form, signals an error."))

(setf (documentation 'continue 'function)
      (format
       nil
       "Invokes the most recent CONTINUE restart. If the optional~@
        condition argument is provided, instead the most recent~@
        CONTINUE restart that is not associated with any other condition.~@
        If no CONTINUE restart is available, returns NIL."))

(setf (documentation 'muffle-warning 'function)
      (format
       nil
       "Invokes the most recent MUFFLE-WARNING restart. If the~@
        optional condition argument is provided, instead the most~@
        recent MUFFLE-WARNING restart that is not associated with~@
        any other condition. If no MUFFLE-WARNING restart is available,~@
        signals an error."))

(setf (documentation 'store-value 'function)
      (format
       nil
       "Invokes the most recent STORE-VALUE restart. If the~@
        optional condition argument is provided, instead the most~@
        recent STORE-VALUE restart that is not associated with~@
        any other condition. If no STORE-VALUE restart is available,~@
        returns NIL."))

(setf (documentation 'use-value 'function)
      (format
       nil
       "Invokes the most recent USE-VALUE restart. If the~@
        optional condition argument is provided, instead the~@
        most recent USE-VALUE restart that is not associated~@
        with any other condition. If no USE-VALUE restart is available,~@
        returns NIL."))
